package com.example.robertluozizhao.java.design.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created by Lzz on 4/11/2020.
 */

public class ActionInvocationHandler implements InvocationHandler{

    private Object action;

    public ActionInvocationHandler(Object action) {
        this.action = action;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("代理执行(前)："+method.getName());
        method.invoke(action,args);
        System.out.println("代理执行(后)："+method.getName());
        return null;
    }
}
